"""
需求：
1. 访问TPshop搜索商品的接口，通过查询字符串的方式传递搜索的关键字 iPhone ，并查看响应数据
2. 请求路径格式为： http://localhost/Home/Goods/search.html?q=iPhone
"""
# 導包
import requests

# 發放請求
# 直接通過url傳遞參數
# response = requests.get(url="http://localhost/Home/Goods/search.html", params="q=iPhone")

# 透過params傳遞參數
# (1) 字符串
url = "http://localhost/Home/Goods/search.html"
params = "q=iPhone"
# response = requests.get(url=url, params=params)

# (2) 字典
dict = {
    "q": "iPhone"
}
# response = requests.get(url=url, params=dict)
response = requests.get(url, dict)
# 查看響應
response.encoding = "utf-8"
print(response.text)